package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.SelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsWarehouseLocation;
import com.ruoyi.system.service.IWmsWarehouseLocationService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货位信息Controller
 *
 * @author ruoyi
 * @date 2025-06-17
 */
@RestController
@RequestMapping("/system/wmsWarehouseLocation")
public class WmsWarehouseLocationController extends BaseController
{
    @Autowired
    private IWmsWarehouseLocationService wmsWarehouseLocationService;

    /**
     * 查询货位信息列表
     */
    @SaCheckPermission("system:wmsWarehouseLocation:list")
    @GetMapping("/list")
    public TableDataInfo<WmsWarehouseLocation> list(WmsWarehouseLocation wmsWarehouseLocation, PageQuery pageQuery)
    {
        return wmsWarehouseLocationService.selectWmsWarehouseLocationList(wmsWarehouseLocation,pageQuery);
    }

    /**
     * 导出货位信息列表
     */
    /*@SaCheckPermission("system:wmsWarehouseLocation:export")
    @Log(title = "货位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehouseLocation wmsWarehouseLocation)
    {
        List<WmsWarehouseLocation> list = wmsWarehouseLocationService.selectWmsWarehouseLocationList(wmsWarehouseLocation);
        ExcelUtil<WmsWarehouseLocation> util = new ExcelUtil<WmsWarehouseLocation>(WmsWarehouseLocation.class);
        util.exportExcel(response, list, "货位信息数据");
    }*/

    /**
     * 获取货位信息详细信息
     */
    @SaCheckPermission("system:wmsWarehouseLocation:query")
    @GetMapping(value = "/{locationId}")
    public R<WmsWarehouseLocation> getInfo(@PathVariable("locationId") Long locationId)
    {
        return R.ok(wmsWarehouseLocationService.selectWmsWarehouseLocationByLocationId(locationId));
    }

    /**
     * 新增货位信息
     */
    @SaCheckPermission("system:wmsWarehouseLocation:add")
    @Log(title = "货位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsWarehouseLocation wmsWarehouseLocation)
    {
        return toAjax(wmsWarehouseLocationService.insertWmsWarehouseLocation(wmsWarehouseLocation));
    }

    /**
     * 修改货位信息
     */
    @SaCheckPermission("system:wmsWarehouseLocation:edit")
    @Log(title = "货位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsWarehouseLocation wmsWarehouseLocation)
    {
        return toAjax(wmsWarehouseLocationService.updateWmsWarehouseLocation(wmsWarehouseLocation));
    }

    /**
     * 删除货位信息
     */
    @SaCheckPermission("system:wmsWarehouseLocation:remove")
    @Log(title = "货位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{locationIds}")
    public R<Void> remove(@PathVariable Long[] locationIds)
    {
        return toAjax(wmsWarehouseLocationService.deleteWmsWarehouseLocationByLocationIds(locationIds));
    }

    @SaCheckPermission("system:wmsWarehouseLocation:list")
    @GetMapping("/getWmsWarehouseLocationSelect")
    public R<List<SelectVo>> getWmsWarehouseLocationSelect(){
        return R.ok(wmsWarehouseLocationService.getWmsWarehouseLocationSelect());
    }

    @SaCheckPermission("system:wmsWarehouseLocation:list")
    @GetMapping("/getWmsWarehouseLocationSelectByRackId")
    public R<List<SelectVo>> getWmsWarehouseLocationSelectByRackId(@RequestParam Long rackId){
        return R.ok(wmsWarehouseLocationService.getWmsWarehouseLocationSelectByRackId(rackId));
    }
}
